package practice;

import java.util.Random;

class RandomArray{
    private int max;
    private int min;
    private int arr[] = new int[10];

    public RandomArray(){
        for (int i = 0; i < 10 ; i++){
            Random r = new Random();
            arr[i] = r.nextInt(100) + 1;
        }
    }
    public void showArray(){
        for (int i = 0; i < 10 ; i++){
            System.out.print(arr[i] + " ");
        }
        System.out.println();
    }
    public int Average(){
        int num =arr[0];
        for (int i = 1; i < arr.length ; i++){
            num += arr[i];
        }
        num = num / arr.length;
        return num;
    }
    public int AddAll(){
        int all = arr[0];
        for (int i = 1; i < arr.length ; i++){
            all += arr[i];
        }
        return all;
    }
    public int LessThanTheAverage(){
        int all = 0;
        for (int i = 0; i < arr.length ; i++){
            if(arr[i] < Average()){
                all++;
            }
        }
        return all;
    }
}



public class 随机数存入数组 {
    public static void main(String[] args) {
        RandomArray r = new RandomArray();
        r.showArray();
        System.out.println(r.Average());
        System.out.println("所有的和"+ r.AddAll());
        System.out.println("小于平均数的共有" + r.LessThanTheAverage());
    }
}
